<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>修改用户</title>
<link href="__PUBLIC__/admin/css/xc.min.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/admin/css/xc.admin.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/lib/iconfont/iconfont.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/common-1.0.js"></script>
<script type="text/javascript" src="__PUBLIC__/lib/layer/layer.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.js"></script> 
<script type="text/javascript" src="__PUBLIC__/admin/js/xc.admin.js"></script>

</head>
<body>
<div class="pd-5">
  <form action="#" method="post" class="form form-horizontal" id="myform">
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>会员编号：</label>
      <div class="formControls col-5" style="margin-top:3px;">{$re.us_uid}</div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>直推会员：</label>
      <div class="formControls col-5" style="margin-top:3px;">
        <if condition='($re.us_pid neq 0)'>
        <input type="text" id="pid" name="pid" value="{$re.us_pid}" readonly class="input-text" style="background-color:#ccc" placeholder="请输入直推会员ID">
        <else />无</if>
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>会员姓名：</label>
      <div class="formControls col-5">
        <input type="text" id="uname" name="uname" value="{$re.us_name}" class="input-text" placeholder="请输入会员真实姓名">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>手机号：</label>
      <div class="formControls col-5">
        <input type="text" id="phone" name="phone" value="{$re.us_phone}" class="input-text" placeholder="请输入您常用的手机号">
      </div>
      <a class="btn btn-success radius" onClick="upCode()"><i class='Hui-iconfont'>&#xe6cb;</i> 更新推广码</a>
    </div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>会员信息：</label>
			<div class="formControls col-5" style="margin-top:3px;">{$re.us_city}</div>
		</div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>伞下人数：</label>
			<div class="formControls col-5" style="margin-top:3px;">{$re.us_scount}</div>
		</div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>伞下业绩：</label>
			<div class="formControls col-5" style="margin-top:3px;">{$re.us_smoney}</div>
		</div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>登陆密码：</label>
      <div class="formControls col-5">
        <input type="text" id="upwd" name="upwd" class="input-text" placeholder="无需更改请为空">
      </div>
    </div>
    <div class="row cl">
      <label class="form-label col-3"><span class="c-red">*</span>安全密码：</label>
      <div class="formControls col-5">
        <input type="text" id="upwds" name="upwds" class="input-text" placeholder="无需更改请为空">
      </div>
    </div>
    <input type="hidden" id="id" name="id" value="{$re.us_uid}">
    <div class="row cl">
      <div class="col-9 col-offset-3">
        <button type="button" id="sub" name="sub" class="btn btn-primary radius" onClick="checkSubmit()"><i class='Hui-iconfont'>&#xe632;</i> 保存</button>
        <button class="btn btn-default radius" type="button" onClick="layer_close();"><i class='Hui-iconfont'>&#xe66b;</i> 取消</button>
      </div>
    </div>
  </form>
</div>
<script type="text/javascript">
//按回车件触发提交
document.onkeydown=function(event){
	var e = event || window.event || arguments.callee.caller.arguments[0];
	if(e && e.keyCode==13){ // enter 键
		checkSubmit();
	}
}; 
//提交数据
function checkSubmit()
{
	var una = $.trim($('#uname').val());
	var pho = $.trim($('#phone').val());
	var car = $.trim($('#card').val());
	if(una == ''){
		layer.msg('会员真实姓名不能为空!', {icon: 2});
		return false;
	}if(pho == ''){
		layer.msg('会员手机不能为空!', {icon: 2});
		return false;
	}if(!checkMobile(pho)){
		layer.msg('手机号码格式不正确!', {icon: 2});
		return false;
	}
	$.ajax({
		type : 'post',
		url : '__MODULE__/User/userEdit',
		data : $("#myform").serialize(),
		dataType : 'json',
		success : function(res){
			if(res.status == 1){
				layer.msg(res.msg,{icon:1,time:2000},function(){
					// 先获取窗口索引，才能关闭窗口  
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);
				});
				parent.call_back_fun('success');
			}else{
				layer.msg(res.msg, {icon: 2});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.alert('网络失败，请刷新页面后重试',{icon:2});
		}
	})
}
//更新二维码
function upCode(){
	var phone = $.trim($('#phone').val());
	$.ajax({
		type : 'post',
		url : '__MODULE__/User/updateCode',
		data : {'phone':phone},
		dataType : 'json',
		success : function(res){
			if(res.status == 1){
				layer.msg(res.msg, {icon: 1});
			}
		},
		error : function(XMLHttpRequest, textStatus, errorThrown) {
			layer.alert('网络失败，请刷新页面后重试',{icon:2});
		}
	})
}
</script>
</body>
</html>